<template>
	<view>
		<view class="menu-item">
			<view class="menu-banner" v-for="(m,i) in menuList" :key="i">
				<text class="title">{{m.title}}</text>
				<image class="banner" :src="m.pic" @click="goMenu(m.menuId)"/>
				</image>
				<text class="count">共{{m.foodQty}}道菜</text>
				<view class="desc">
					<text class="desc-item">{{m.hits}}人浏览</text>
					<text class='desc-item'>{{m.favorites}}收藏</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuList: []
			}
		},
		methods: {
			getData() {
				uni.request({
					url: 'https://appfly.cn/api/cookbookCommon/foodMenuList',
					success: (res) => {
						this.menuList = res.data.data
						// console.log(res.data);//输出
						console.log(this.menuList);
					}
				});
			},
			goMenu(id){
				uni.navigateTo({
				     url:`/pages/menuCata/menuCata?id=${id}`
				 })
			}
		},
		mounted() {
			this.getData()
		}
	}
</script>

<style lang="scss">
	.menu-item{
		width: 93vw;
		padding: 10px 12px;
		.title{
			font-size: 20px;
			font-weight: 700;
		}
		.desc{
			margin-bottom: 20px;
			display: flex;
			justify-content: space-between;
			color: #999;

		}
		.menu-banner{
			position: relative;
			.banner{
				// position: absolute;
				width: 93vw;
				height: 200px;
				border-radius: 8px;
				margin: 10px 0;
			}
			.count{
				position: absolute;
				top: 50%;
				left:50%;
				transform: translateX(-50%);
				font-size: 20px;
				font-weight: 700;
				color: aliceblue;
				letter-spacing: 2px;
			}
		}
	}
</style>
